package common;

import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.View;

import java.lang.reflect.Field;

/**
 * Created by ilioili on 2015/1/12.
 */
public class ViewUtil {


    public static void loadView(Fragment fragment, View rootView) {
        Field[] fields = fragment.getClass().getDeclaredFields();
        try {
            for (Field field : fields) {
                if (field.isAnnotationPresent(BaseActivity.id.class)) {
                    field.setAccessible(true);
                    field.set(fragment, rootView.findViewById(field.getAnnotation(BaseActivity.id.class).value()));
                }
            }
        } catch (Exception e) {
            Log.e(BaseActivity.class.getName(), e.toString());
        }
    }

}

